Skip to content

Use user timezone - #93447

Merged
pecanoro merged 18 commits into
mainfrom
cmartins-useUserTimezone
Jun 15, 2026
Merged

pecanoro merged 18 commits into
mainfrom
cmartins-useUserTimezone

Conversation

@luacmartins

@luacmartins luacmartins commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Concierge VictoryChart subtitle labels (As of: ...) are emitted by the server as UTC wall-clock text. Localize them at render time in VictoryChartLabel using the viewer's selected timezone.

Fixed Issues

$ #93443

Tests

  1. Set your account timezone to something non-UTC (e.g. America/Los_Angeles).
  2. Open a Concierge chat message with a VictoryChart that has an As of: subtitle under the chart title.
  3. Confirm the subtitle time matches your timezone, not UTC.
  4. Change your timezone in settings and reopen the chat; confirm the subtitle updates.
  5. Confirm other chart labels (title, axis labels) are unchanged.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests — localization is client-side and does not require network.

QA Steps

Same as Tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Screen.Recording.2026-06-12.at.11.25.35.AM.mov
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@luacmartins luacmartins self-assigned this Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...artRenderer/utils/localizeVictoryChartLabelText.ts 100.00% <100.00%> (ø)
...ChartRenderer/components/VictoryChartCartesian.tsx 0.00% <0.00%> (ø)
...toryChartRenderer/components/VictoryChartPolar.tsx 0.00% <0.00%> (ø)
src/hooks/useCurrentTimezone.ts 0.00% <0.00%> (ø)
...toryChartRenderer/components/VictoryChartLabel.tsx 0.00% <0.00%> (ø)
... and 37 files with indirect coverage changes

@luacmartins
luacmartins marked this pull request as ready for review June 12, 2026 17:42
@luacmartins
luacmartins requested review from a team as code owners June 12, 2026 17:42
@melvin-bot

melvin-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

@mkhutornyi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed request for a team June 12, 2026 17:42

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 31e6e2bbda

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@melvin-bot
melvin-bot Bot requested a review from pecanoro June 14, 2026 14:00
@melvin-bot

melvin-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

@pecanoro Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: baec8e9b70

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@MelvinBot

Copy link
Copy Markdown
Contributor

Code Review

The approach is sound and the tests are a nice touch. One real correctness bug (DST), plus a couple of things worth confirming before merge.

1. parseDateAsUTC shifts by an hour for DST-transition times 🐛

localizeVictoryChartLabelText.ts:28 parses the string into a device-local Date, then rebuilds it with Date.UTC(...getHours(), getMinutes()...). That round-trip is only lossless when the parsed wall-clock time actually exists (unambiguously) in the device's local zone.

For a UTC time that lands in the viewer's DST spring-forward gap (or fall-back overlap), getHours() returns a normalized value:

  • Device TZ America/New_York, label As of: Mar 8, 2026 at 2:30 AM (server UTC).
  • parse(...) → new Date(2026, 2, 8, 2, 30). 02:30 doesn't exist that day, so JS normalizes it to 03:30 EDT and getHours() returns 3.
  • Date.UTC(..., 3, 30) → 2026-03-08T03:30:00Z instead of 02:30:00Z → the "As of" time renders one hour off.

It's a narrow window (a couple of hours per year per zone), but it's a silent wrong value. Safer to parse straight to UTC rather than via a local Date — e.g. pull the numeric components from the regex/parse and build the UTC date without ever materializing a local-zone Date, or reformat to an ISO-ish string and use toDate(text, {timeZone: 'UTC'}). The existing tests pass only because they don't cover a DST-gap input.

2. Month/meridiem stay English regardless of app language

localizeVictoryChartLabelText.ts:53 calls formatInTimeZoneWithFallback with no date-fns locale option, and CHART_DISPLAY_FORMAT uses MMM + aa. So an es/fr/ja user still gets Jun … AM. If the PR's localization goal is timezone-only, this is fine to ignore — but worth a conscious call since the label is now being rewritten client-side rather than passed through.

3. \s* in the regex can swallow a newline and collapse a multi-line label

localizeVictoryChartLabelText.ts:6 — /^As of:\s*(.+)$/i. \s matches \n, so if the server ever emits the label and date on separate lines ("As of:\nJun 5, 2026 at 06:47 PM"), this matches and returns a single line. VictoryChartLabel then split('\n')s the result and applies per-line (color[index], fontSize[index]…) styling, so the second line and its styling get dropped. Low confidence since it depends on the server format — if As of: and the timestamp are always one line, no issue. Worth confirming.

Also looked at (no action needed)
  • VictoryChartPieLabel doesn't pass timezone — fine. Pie slice labels are category names, never As of: timestamps; the pie chart's As of: subtitle renders through the VictoryChartPolar labelItems path, which now passes timezone.
  • useCurrentTimezone logged-out / missing personalDetails — fine. The provider is mounted at the App root and ?.timezone ?? CONST.DEFAULT_TIME_ZONE covers the missing case.
  • formatInTimeZoneWithFallback unguarded catch branch (DateUtils.ts:935) — pre-existing; if the automatic-timezone path yields an IANA zone not in timezoneNewToBackwardMap and the first formatInTimeZone throws, the fallback passes undefined and throws uncaught. Not introduced here, but the new chart-label path can now reach it.

Reply with @MelvinBot <feedback> to refine this review.

@luacmartins

Copy link
Copy Markdown
Contributor Author
  1. I think that's a pretty small edge case. NAB
  2. Chart data is not translated, so that's ok
  3. That label is single line

@pecanoro
pecanoro merged commit faeb512 into main Jun 15, 2026
37 of 39 checks passed
@pecanoro
pecanoro deleted the cmartins-useUserTimezone branch June 15, 2026 20:35
@github-actions

Copy link
Copy Markdown
Contributor

🚧 @pecanoro has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Jun 16, 2026
46 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/pecanoro in version: 9.4.9-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Help site review: no changes required.

This PR is a client-side rendering bug fix. It localizes the As of: ... subtitle timestamps on Concierge spend-analysis charts (VictoryChartLabel) so they display in the viewer's selected timezone instead of raw server UTC.

It introduces no new user-facing feature, setting, button, tab, or workflow — it only corrects how an existing timestamp is displayed. The only related help article, How Concierge Analyzes Spend, does not document chart timestamps, UTC, or timezone behavior, so there is nothing to update there.

No draft docs PR was created.

@luacmartins, if you believe this behavior should be documented on the help site, let me know and I'll draft a PR.

@mitarachim

mitarachim commented Jun 17, 2026 •

Copy link
Copy Markdown

@luacmartins This PR is failing because of a regression issue #93791

The issue is reproducible in: Web, iOS App, Android App

Bug7183299_1781691271843.809050d9a22f5c96ea4d42e82f312978.mp4

@mkhutornyi

Copy link
Copy Markdown

Not regression.
As of: 2026-06-16 00:00 (Concierge generated) doesn't match BE format.

/** Matches server `EXP_CHAT_COMMENT_DATETIME` (`M j, Y \a\t h:i A`) with and without a leading zero on the hour. */
const SERVER_AS_OF_PARSE_FORMATS = ['MMM d, yyyy hh:mm aa', 'MMM d, yyyy h:mm aa'] as const;

@luacmartins

Copy link
Copy Markdown
Contributor Author

Yea, I'm confused. @mitarachim how did you get that Concierge report?

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.4.9-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@mitarachim

Copy link
Copy Markdown

Hello @luacmartins we use below step (#93791) to get Concierge report
Screenshot 2026-06-18 at 4 50 04 AM

@luacmartins

Copy link
Copy Markdown
Contributor Author

Yea, that's not right. I can generate a report for the account. Can you tell me the email, policyID and #admins room reportID please?

@mitarachim

Copy link
Copy Markdown

here the details @luacmartins
email: piyootest+ba2@gmail.com
policyID: F6BEDB88EA6D8E4D
#admin room reportID: 1448250064568121

@luacmartins

Copy link
Copy Markdown
Contributor Author

@mitarachim I generated a report for that account, although it seems like that account doesn't have spend in May so the charts won't show up. Can you create a few expenses in May please?

@daledah

daledah commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@luacmartins, this issue was reported using AI-generated VictoryCharts (by prompting Concierge). Should we close this, or expand the parser to handle AI-generated formats too?

@mitarachim

Copy link
Copy Markdown

@luacmartins tester already created several expenses on May

image

then at the first test on the PR after creating those expenses, the time zone still doesn't updated to my time zone. but there's a note on the VictoryChart that the timezone not provided

vicchart.mp4

after that, I tried again with additional As of: date and time" based on my time zone in my profile (Asia/Jakarta) on the prompts, the subtitle is not generated. But Concierge stated "For your VictoryCharts subtitle, use a string like As of: 2026-06-19 14:40 (Asia/Jakarta) under the chart title; you can update this with the current Asia/Jakarta time whenever you refresh the data". Then I tried to refresh it for several times, the subtitle still not displayed

vicchart.2.mp4

@luacmartins

Copy link
Copy Markdown
Contributor Author

@mitarachim those test steps are incorrect. I generated another VirtualCFO report for that account, but it seems like there's still no data. I'll test this one myself

@luacmartins

Copy link
Copy Markdown
Contributor Author

Tested this internally and it's a pass.

@quinthar quinthar added the #ai label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants